<!--<!doctype html>-->
<!--<html lang="zh_CN">-->
<!--<head>-->
<!--    <meta charset="UTF-8">-->
<!--    <meta name="viewport"-->
<!--          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">-->
<!--    <meta http-equiv="X-UA-Compatible" content="ie=edge">-->
<!--    <title>Document</title>-->
<!--    <script src="lib/vue.js"></script>-->
<!--</head>-->
<!--<body>-->
<!--<div id="app">-->
<!--    <my-header></my-header>-->
<!--    <my-header></my-header>-->
<!--    <my-header></my-header>-->
<!--</div>-->
<!--</body>-->

<!--<template id="header">-->
<!--    <button @click="add">{{count}}</button>-->
<!--</template>-->

<!--<script>-->
<!--    // 局部注册组件-->
<!--    new Vue({-->
<!--        el: "#app",-->
<!--        components: {-->
<!--            "my-header": {-->
<!--                template:`#header`,-->
<!--                data(){-->
<!--                    return {-->
<!--                        msg: "hello component",-->
<!--                        count: 10,-->
<!--                    }-->
<!--                },-->
<!--                methods:{-->
<!--                    add(){-->
<!--                        this.count++;-->
<!--                    }-->
<!--                }-->
<!--            },-->

<!--        }-->
<!--    })-->
<!--</script>-->
<!--</html>-->


<!doctype html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>局部注册组件</title>
    <script src="lib/vue.js"></script>
</head>
<body>
<div id="app">
    <my-header></my-header>
    <my-header></my-header>
    <my-header></my-header>
</div>
</body>

<template id="header">
    <header>
        标题：{{ msg }}
        <button @click="add">{{count}}</button>
    </header>
</template>

<script>
    new Vue({
        el: "#app",
        components:{
            "my-header": {
                template: `#header`,
                data() {
                    return {
                        count : 0,
                        msg: "Hello component!"
                    }
                },
                methods: {
                    add(){
                        this.count++;
                    }
                }
            }
        }
    })
</script>

</html>